package com.ai.ly.goodsautocat.vo;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class SampleVO {
    
    private static Comparator<Integer> comparator=
            new Comparator<Integer>() {
        public int compare(Integer obj1, Integer obj2) {
            // 升序排序
            return obj1.compareTo(obj2);
        }
    };  
    
    private String gdsName;
    
    Map<Integer, Integer> indexCountMap;// 第几位的单词出现了多少次。index从1开始

    int xLength;// x的长度
    
    public SampleVO() {
    }
    
    public SampleVO(int xLength) {
        this.xLength = xLength;
        indexCountMap =  new TreeMap<Integer, Integer>(comparator);
    }
    
    public void addIndexCount(int index) {
        Integer count=indexCountMap.get(index);
        if (count==null) {
            count=1;
        }else {
            count++;
        }
        indexCountMap.put(index, count);
    }
    
    public boolean isInDict() {
        return indexCountMap.size() > 0;
    }
    
    public Map<Integer, Integer> getIndecCountMap(){
        return this.indexCountMap;
    }

    public int getxLength() {
        return xLength;
    }

    public int getWordCount(int index) {
        Integer result=indexCountMap.get(index);
        if (result==null) {
            return 0;
        }
        return result;
    }

    public String getGdsName() {
        return gdsName;
    }

    public void setGdsName(String gdsName) {
        this.gdsName = gdsName;
    }
    
}
